#ifndef REPORTING_H_INCLUDED
#define REPORTING_H_INCLUDED


#define REPORTING_NO_ERROR		(0)
#define REPORTING_WITH_MESSAGE

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

#define GOTO_WITH_CODE(ec, lbl) do { \
	reporting_report(ec, #ec " - " __FILE__ "(" TOSTRING(__LINE__) ")"); \
	goto lbl; \
	} while (0)

#define RETURN_WITH_CODE2(ec, retval) do { \
	reporting_report(ec, #ec " - " __FILE__ "(" TOSTRING(__LINE__) ")"); \
	return retval; \
	} while (0)

#define RETURN_WITH_CODE_IF2(ec, cond, retval) do { \
	if ((cond)) { \
		reporting_report(ec, #ec " - " __FILE__ "(" TOSTRING(__LINE__) ")"); \
		return retval; \
	}} while (0)

#define RETURN_WITH_CODE(ec) do { \
	reporting_report(ec, #ec " - " __FILE__ "(" TOSTRING(__LINE__) ")"); \
	return -1; \
	} while (0)

#define RETURN_WITH_CODE_IF(ec, cond) do { \
	if ((cond)) { \
		reporting_report(ec, #ec " - " __FILE__ "(" TOSTRING(__LINE__) ")"); \
		return -1; \
	}} while (0)


void reporting_report(int ec, const char * message);
void reporting_clear(void);
int reporting_get(void);
int reporting_is_error(int ec);
const char * reporting_get_message(void);


#endif
